home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 March / maximum-cd-2000-03.iso / Quake3 Game Source / Q3AGameSource.exe / Main / ui_network.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-18  |  8.2 KB  |  262 lines

  1. // Copyright (C) 1999-2000 Id Software, Inc.
  2. //
  3. /*
  4. =======================================================================
  5.  
  6. NETWORK OPTIONS MENU
  7.  
  8. =======================================================================
  9. */
  10.  
  11. #include "ui_local.h"
  12.  
  13.  
  14. #define ART_FRAMEL            "menu/art/frame2_l"
  15. #define ART_FRAMER            "menu/art/frame1_r"
  16. #define ART_BACK0            "menu/art/back_0"
  17. #define ART_BACK1            "menu/art/back_1"
  18.  
  19. #define ID_GRAPHICS            10
  20. #define ID_DISPLAY            11
  21. #define ID_SOUND            12
  22. #define ID_NETWORK            13
  23. #define ID_RATE                14
  24. #define ID_BACK                15
  25.  
  26.  
  27. static const char *rate_items[] = {
  28.     "<= 28.8K",
  29.     "33.6K",
  30.     "56K",
  31.     "ISDN",
  32.     "LAN/Cable/xDSL",
  33.     0
  34. };
  35.  
  36. typedef struct {
  37.     menuframework_s    menu;
  38.  
  39.     menutext_s        banner;
  40.     menubitmap_s    framel;
  41.     menubitmap_s    framer;
  42.  
  43.     menutext_s        graphics;
  44.     menutext_s        display;
  45.     menutext_s        sound;
  46.     menutext_s        network;
  47.  
  48.     menulist_s        rate;
  49.  
  50.     menubitmap_s    back;
  51. } networkOptionsInfo_t;
  52.  
  53. static networkOptionsInfo_t    networkOptionsInfo;
  54.  
  55.  
  56. /*
  57. =================
  58. UI_NetworkOptionsMenu_Event
  59. =================
  60. */
  61. static void UI_NetworkOptionsMenu_Event( void* ptr, int event ) {
  62.     if( event != QM_ACTIVATED ) {
  63.         return;
  64.     }
  65.  
  66.     switch( ((menucommon_s*)ptr)->id ) {
  67.     case ID_GRAPHICS:
  68.         UI_PopMenu();
  69.         UI_GraphicsOptionsMenu();
  70.         break;
  71.  
  72.     case ID_DISPLAY:
  73.         UI_PopMenu();
  74.         UI_DisplayOptionsMenu();
  75.         break;
  76.  
  77.     case ID_SOUND:
  78.         UI_PopMenu();
  79.         UI_SoundOptionsMenu();
  80.         break;
  81.  
  82.     case ID_NETWORK:
  83.         break;
  84.  
  85.     case ID_RATE:
  86.         if( networkOptionsInfo.rate.curvalue == 0 ) {
  87.             trap_Cvar_SetValue( "rate", 2500 );
  88.         }
  89.         else if( networkOptionsInfo.rate.curvalue == 1 ) {
  90.             trap_Cvar_SetValue( "rate", 3000 );
  91.         }
  92.         else if( networkOptionsInfo.rate.curvalue == 2 ) {
  93.             trap_Cvar_SetValue( "rate", 4000 );
  94.         }
  95.         else if( networkOptionsInfo.rate.curvalue == 3 ) {
  96.             trap_Cvar_SetValue( "rate", 5000 );
  97.         }
  98.         else if( networkOptionsInfo.rate.curvalue == 4 ) {
  99.             trap_Cvar_SetValue( "rate", 25000 );
  100.         }
  101.         break;
  102.  
  103.     case ID_BACK:
  104.         UI_PopMenu();
  105.         break;
  106.     }
  107. }
  108.  
  109.  
  110. /*
  111. ===============
  112. UI_NetworkOptionsMenu_Init
  113. ===============
  114. */
  115. static void UI_NetworkOptionsMenu_Init( void ) {
  116.     int        y;
  117.     int        rate;
  118.  
  119.     memset( &networkOptionsInfo, 0, sizeof(networkOptionsInfo) );
  120.  
  121.     UI_NetworkOptionsMenu_Cache();
  122.     networkOptionsInfo.menu.wrapAround = qtrue;
  123.     networkOptionsInfo.menu.fullscreen = qtrue;
  124.  
  125.     networkOptionsInfo.banner.generic.type        = MTYPE_BTEXT;
  126.     networkOptionsInfo.banner.generic.flags        = QMF_CENTER_JUSTIFY;
  127.     networkOptionsInfo.banner.generic.x            = 320;
  128.     networkOptionsInfo.banner.generic.y            = 16;
  129.     networkOptionsInfo.banner.string            = "SYSTEM SETUP";
  130.     networkOptionsInfo.banner.color                = color_white;
  131.     networkOptionsInfo.banner.style                = UI_CENTER;
  132.  
  133.     networkOptionsInfo.framel.generic.type        = MTYPE_BITMAP;
  134.     networkOptionsInfo.framel.generic.name        = ART_FRAMEL;
  135.     networkOptionsInfo.framel.generic.flags        = QMF_INACTIVE;
  136.     networkOptionsInfo.framel.generic.x            = 0;  
  137.     networkOptionsInfo.framel.generic.y            = 78;
  138.     networkOptionsInfo.framel.width                = 256;
  139.     networkOptionsInfo.framel.height            = 329;
  140.  
  141.     networkOptionsInfo.framer.generic.type        = MTYPE_BITMAP;
  142.     networkOptionsInfo.framer.generic.name        = ART_FRAMER;
  143.     networkOptionsInfo.framer.generic.flags        = QMF_INACTIVE;
  144.     networkOptionsInfo.framer.generic.x            = 376;
  145.     networkOptionsInfo.framer.generic.y            = 76;
  146.     networkOptionsInfo.framer.width                = 256;
  147.     networkOptionsInfo.framer.height            = 334;
  148.  
  149.     networkOptionsInfo.graphics.generic.type        = MTYPE_PTEXT;
  150.     networkOptionsInfo.graphics.generic.flags        = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
  151.     networkOptionsInfo.graphics.generic.id            = ID_GRAPHICS;
  152.     networkOptionsInfo.graphics.generic.callback    = UI_NetworkOptionsMenu_Event;
  153.     networkOptionsInfo.graphics.generic.x            = 216;
  154.     networkOptionsInfo.graphics.generic.y            = 240 - 2 * PROP_HEIGHT;
  155.     networkOptionsInfo.graphics.string                = "GRAPHICS";
  156.     networkOptionsInfo.graphics.style                = UI_RIGHT;
  157.     networkOptionsInfo.graphics.color                = color_red;
  158.  
  159.     networkOptionsInfo.display.generic.type            = MTYPE_PTEXT;
  160.     networkOptionsInfo.display.generic.flags        = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
  161.     networkOptionsInfo.display.generic.id            = ID_DISPLAY;
  162.     networkOptionsInfo.display.generic.callback        = UI_NetworkOptionsMenu_Event;
  163.     networkOptionsInfo.display.generic.x            = 216;
  164.     networkOptionsInfo.display.generic.y            = 240 - PROP_HEIGHT;
  165.     networkOptionsInfo.display.string                = "DISPLAY";
  166.     networkOptionsInfo.display.style                = UI_RIGHT;
  167.     networkOptionsInfo.display.color                = color_red;
  168.  
  169.     networkOptionsInfo.sound.generic.type            = MTYPE_PTEXT;
  170.     networkOptionsInfo.sound.generic.flags            = QMF_RIGHT_JUSTIFY|QMF_PULSEIFFOCUS;
  171.     networkOptionsInfo.sound.generic.id                = ID_SOUND;
  172.     networkOptionsInfo.sound.generic.callback        = UI_NetworkOptionsMenu_Event;
  173.     networkOptionsInfo.sound.generic.x                = 216;
  174.     networkOptionsInfo.sound.generic.y                = 240;
  175.     networkOptionsInfo.sound.string                    = "SOUND";
  176.     networkOptionsInfo.sound.style                    = UI_RIGHT;
  177.     networkOptionsInfo.sound.color                    = color_red;
  178.  
  179.     networkOptionsInfo.network.generic.type            = MTYPE_PTEXT;
  180.     networkOptionsInfo.network.generic.flags        = QMF_RIGHT_JUSTIFY;
  181.     networkOptionsInfo.network.generic.id            = ID_NETWORK;
  182.     networkOptionsInfo.network.generic.callback        = UI_NetworkOptionsMenu_Event;
  183.     networkOptionsInfo.network.generic.x            = 216;
  184.     networkOptionsInfo.network.generic.y            = 240 + PROP_HEIGHT;
  185.     networkOptionsInfo.network.string                = "NETWORK";
  186.     networkOptionsInfo.network.style                = UI_RIGHT;
  187.     networkOptionsInfo.network.color                = color_red;
  188.  
  189.     y = 240 - 1 * (BIGCHAR_HEIGHT+2);
  190.     networkOptionsInfo.rate.generic.type        = MTYPE_SPINCONTROL;
  191.     networkOptionsInfo.rate.generic.name        = "Data Rate:";
  192.     networkOptionsInfo.rate.generic.flags        = QMF_PULSEIFFOCUS|QMF_SMALLFONT;
  193.     networkOptionsInfo.rate.generic.callback    = UI_NetworkOptionsMenu_Event;
  194.     networkOptionsInfo.rate.generic.id            = ID_RATE;
  195.     networkOptionsInfo.rate.generic.x            = 400;
  196.     networkOptionsInfo.rate.generic.y            = y;
  197.     networkOptionsInfo.rate.itemnames            = rate_items;
  198.  
  199.     networkOptionsInfo.back.generic.type        = MTYPE_BITMAP;
  200.     networkOptionsInfo.back.generic.name        = ART_BACK0;
  201.     networkOptionsInfo.back.generic.flags        = QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS;
  202.     networkOptionsInfo.back.generic.callback    = UI_NetworkOptionsMenu_Event;
  203.     networkOptionsInfo.back.generic.id            = ID_BACK;
  204.     networkOptionsInfo.back.generic.x            = 0;
  205.     networkOptionsInfo.back.generic.y            = 480-64;
  206.     networkOptionsInfo.back.width                = 128;
  207.     networkOptionsInfo.back.height                = 64;
  208.     networkOptionsInfo.back.focuspic            = ART_BACK1;
  209.  
  210.     Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.banner );
  211.     Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.framel );
  212.     Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.framer );
  213.     Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.graphics );
  214.     Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.display );
  215.     Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.sound );
  216.     Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.network );
  217.     Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.rate );
  218.     Menu_AddItem( &networkOptionsInfo.menu, ( void * ) &networkOptionsInfo.back );
  219.  
  220.     rate = trap_Cvar_VariableValue( "rate" );
  221.     if( rate <= 2500 ) {
  222.         networkOptionsInfo.rate.curvalue = 0;
  223.     }
  224.     else if( rate <= 3000 ) {
  225.         networkOptionsInfo.rate.curvalue = 1;
  226.     }
  227.     else if( rate <= 4000 ) {
  228.         networkOptionsInfo.rate.curvalue = 2;
  229.     }
  230.     else if( rate <= 5000 ) {
  231.         networkOptionsInfo.rate.curvalue = 3;
  232.     }
  233.     else {
  234.         networkOptionsInfo.rate.curvalue = 4;
  235.     }
  236. }
  237.  
  238.  
  239. /*
  240. ===============
  241. UI_NetworkOptionsMenu_Cache
  242. ===============
  243. */
  244. void UI_NetworkOptionsMenu_Cache( void ) {
  245.     trap_R_RegisterShaderNoMip( ART_FRAMEL );
  246.     trap_R_RegisterShaderNoMip( ART_FRAMER );
  247.     trap_R_RegisterShaderNoMip( ART_BACK0 );
  248.     trap_R_RegisterShaderNoMip( ART_BACK1 );
  249. }
  250.  
  251.  
  252. /*
  253. ===============
  254. UI_NetworkOptionsMenu
  255. ===============
  256. */
  257. void UI_NetworkOptionsMenu( void ) {
  258.     UI_NetworkOptionsMenu_Init();
  259.     UI_PushMenu( &networkOptionsInfo.menu );
  260.     Menu_SetCursorToItem( &networkOptionsInfo.menu, &networkOptionsInfo.network );
  261. }
  262.